
//全局默认参数
//顶部导航
var UserBean = null;
var countPage = 1; //总页数
var curPage = 1; //当前页
var limit = 10; //每页显示数量
var itemType = 1;//默认是正在征集
//页面传给后台的参数 每个页面根据查询条件的个数自定义
var queryParam = {keyword:'',pageCount:limit,curPage:curPage,itemType:itemType};


function $$(id){
	return document.getElementById(id);
}

function showpage(){
	$("#jumppage").toggle("slow");
	$("#pagen").val(curPage);
	 
}
/******************
 * 分页填充组建
 * @param page
 * @param id1 顶部分页组建的id
 * @param id2 尾部分页组建的id
 * @param mainid 需要填充的id
 */
 //pagen为当前页码，在多处会调用此值
function setPage(page,id1,mainid){
	curPage = parseInt(page);
	var html = "";
	if(curPage>countPage) curPage = countPage;
	if(countPage>curPage) {
		if(curPage==1){
			html = "首页&nbsp;&nbsp;上一页&nbsp;<a href=\"javascript:queryPage("+(curPage+1)+",'"+id1+"','"+mainid+"')\">下一页</a>&nbsp;<a href=\"javascript:queryPage("+(countPage)+",'"+id1+"','"+mainid+"')\">尾页</a>&nbsp;&nbsp;第"+curPage+"/"+countPage+"页&nbsp;&nbsp;<a href='javascript:showpage()'> 跳转</a>";
			document.getElementById(id1).innerHTML = html;
		}else{
			html = "<a href=\"javascript:queryPage("+(1)+",'"+id1+"','"+mainid+"')\">首页</a>&nbsp;<a href=\"javascript:queryPage("+(curPage-1)+",'"+id1+"','"+mainid+"')\">上一页</a>&nbsp;<a href=\"javascript:queryPage("+(curPage+1)+",'"+id1+"','"+mainid+"')\">下一页</a>&nbsp;<a href=\"javascript:queryPage("+(countPage)+",'"+id1+"','"+mainid+"')\">尾页</a>&nbsp;&nbsp;第"+curPage+"/"+countPage+"页&nbsp;&nbsp;<a href='javascript:showpage()'> 跳转</a>";
			document.getElementById(id1).innerHTML = html;
		}
	}
	else {
		if(curPage>1){
			html = "<a href=\"javascript:queryPage("+(1)+",'"+id1+"','"+mainid+"')\">首页</a>&nbsp;<a href=\"javascript:queryPage("+(curPage-1)+",'"+id1+"','"+mainid+"')\">上一页</a>&nbsp;下一页&nbsp;尾页&nbsp;&nbsp;第"+curPage+"/"+countPage+"页&nbsp;&nbsp;<a href='javascript:showpage()'> 跳转</a>";
			document.getElementById(id1).innerHTML = html;
		}else{
			html = "首页&nbsp;上一页&nbsp;下一页&nbsp;尾页&nbsp;&nbsp;第"+curPage+"/"+countPage+"页&nbsp;&nbsp;<a href='javascript:showpage()'> 跳转</a>";
			document.getElementById(id1).innerHTML = html;
		}
	}
}


/***********
 * 实现queryPage方法
 * @param id1 顶部分页组建的id 
 * @param id2 尾部分页组建的id
 * @param mainid 需要填充的id
 */
function clickGO(id1,mainid) {
	var page = $("#pagen").val();
	if(page>0) {
		queryPage(page,id1,mainid);
		$("#jumppage").hide("slow");
	}
	else alert("请输入页码");
}


function initPageFile(){
	//底部导航

	if($(document).height()<=$(window).height()){
        $(".login_foot").css("position","absolute");
        $(".login_foot").css("top",$(window).height()-66);
	  }
      $(window).resize(function(){   
           $(".login_foot").css("position","static");
		   if($(document).height()<=$(window).height()){
			$(".login_foot").css("position","absolute");
			$(".login_foot").css("top",$(window).height()-66);
	       }
      }); 
      
      $('#jumppage').mouseleave(function(){
    	  $("#jumppage").hide("slow");
	  });
      $('#jumppage').mouseover(function(event){
    	  $("#jumppage").show("slow");
	  });
      
}

dwr.engine.setErrorHandler(errHandler);// 定义全局错误处理器
function errHandler(msg, exception) {
	try {
		Ext.MessageBox.hide();
	} catch (e) {}
	if (msg.toString() != null && msg.toString() != '') {
		if (msg.toString() == 'SeessionTimeout') {
			window.location = "index.html"; //login_action
		} else if (msg.toString().indexOf("code: 0x80004005") != -1) {
			Ext.example.msg('提示', '服务器关闭，请与管理员联系。');
			return false;
		} else if (msg == 'Timeout') {
			Ext.example.msg('提示', '数据库或远程连接超时，请稍后再试。');
			return false;
		} else if (msg.toString().indexOf("MySQLSyntaxErrorException: Table") != -1) {
			Ext.example.msg('提示', '数据库没有这张表。\r\n' + msg);//数据库没有这张表。
			return false;
		} else {
			alert(msg);
			return false;
		}
	} else {
		Ext.example.msg('提示', '后台程序空指针异常');
		return false;
	}
}

